package cn.anxingongyou.anxin.service.impl;

import cn.anxingongyou.anxin.entity.Wages;
import cn.anxingongyou.anxin.mapper.WagesMapper;
import cn.anxingongyou.anxin.service.WagesService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WagesServiceImpl implements WagesService {

    private final WagesMapper wagesMapper;
    @Autowired
    public WagesServiceImpl(WagesMapper wagesMapper) {
        this.wagesMapper = wagesMapper;
    }

    @Override
    public int insert(Wages wages) {
        return wagesMapper.insertSelective(wages);
    }

    @Override
    public int insertList(List<Wages> wagesList) {
        return wagesMapper.insertList(wagesList);
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return wagesMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Wages wages) {
        return wagesMapper.updateByPrimaryKeySelective(wages);
    }

    @Override
    public Wages selectOne(Wages wages) {
        return wagesMapper.selectOne(wages);
    }

    @Override
    public Wages selectOneByPrimaryKey(Long id) {
        return wagesMapper.selectByPrimaryKey(id);
    }

    @Override
    public PageInfo<Wages> page(int pageNum, int pageSize, Wages wages) {
        String orderBy = "id desc";
        PageHelper pageHelper = new PageHelper();
        pageHelper.startPage(pageNum,pageSize,orderBy);
        List<Wages> list = wagesMapper.select(wages);
        PageInfo<Wages> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}
